package com.guigu.tms.aggregation.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.guigu.tms.aggregation.mapper.GoodsTypeMapper;
import com.guigu.tms.commons.aggregation.entity.GoodsType;
import com.guigu.tms.commons.aggregation.entity.OrderCargo;
import com.guigu.tms.aggregation.mapper.OrderCargoMapper;
import com.guigu.tms.aggregation.service.IOrderCargoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 货品总重量  服务实现类
 * </p>
 *
 * @author wj
 * @since 2022-10-21
 */
@Service
public class OrderCargoServiceImpl extends ServiceImpl<OrderCargoMapper, OrderCargo> implements IOrderCargoService {

    @Autowired
    private OrderCargoMapper cargoMapper;
    @Autowired
    private GoodsTypeMapper goodsTypeMapper;

    @Override
    public OrderCargo getCargoByOrderId(String orderId) {
        QueryWrapper<OrderCargo> wrapper=new QueryWrapper<>();
        wrapper.eq("order_id",orderId);
        OrderCargo orderCargo = cargoMapper.selectOne(wrapper);
        orderCargo.setGoodTypeName(goodsTypeMapper.selectById(orderCargo.getGoodsTypeId()).getName());
        return orderCargo;
    }
}
